<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class WxController extends Controller
{
    /**
     * 发红包时是否提示关注公众号
     */
    public function hintAttention()
    {
        $Wchat = $this->wechat();
        $Fans = $Wchat->user->get(auth("member")->user()->openid);
        $Setting = $this->getConfig();
        $_response = response(['message'=>'不提示关注公众号'],402);
        if($Setting->open_attention && $Setting->hint_attention && !$Fans['subscribe']) {
            $_response = response(['data'=>1]);
        }
        return $_response;
    }

    /**
     * 获取微信jsapi权限配置
     */
    public function jsapi()
    {
        $Wechat = $this->wechat();
        $_data = $Wechat->jssdk->buildConfig(
            ['onMenuShareTimeline','onMenuShareAppMessage','updateAppMessageShareData','updateTimelineShareData','chooseWXPay','hideMenuItems','getLocation','scanQRCode','hideAllNonBaseMenuItem','showMenuItems'],
            true,
            false,
            false,
            ['wx-open-subscribe']
        );
        return response(['data'=>$_data]);
    }
}
